<HTML><HEAD><TITLE>nonground(+N, ?Term, -VarList)</TITLE>
</HEAD><BODY>[ <A HREF="index.html">Type Testing</A> | <A HREF="../../index.html">Reference Manual</A> | <A HREF="../../fullindex.html">Alphabetic Index</A> ]
<H1>nonground(+N, ?Term, -VarList)</H1>
Succeeds if Term contains at least N different variables, and returns N of
them in the list VarList.


<DL>
<DT><EM>N</EM></DT>
<DD>Integer.
</DD>
<DT><EM>Term</EM></DT>
<DD>Prolog term.
</DD>
<DT><EM>VarList</EM></DT>
<DD>List or variable.
</DD>
</DL>
<H2>Description</H2>
   Used to test whether Term contains at least N different variables.  The
   argument VarList is unified with a list of exactly N of those variables.
   If Term contains more than N variables, it is not further specified
   which ones will be in the list and in which order.  As usual, attributed
   variables are also considered variables.

<P>
   Note that this predicate is a generalisation of nonground/1 and
   nonground/2 which could be written as:

<P>
<PRE>
    nonground(Term) :- nonground(1, Term, _).
    nonground(Term, Var) :- nonground(1, Term, [Var]).
</PRE>

<H3>Modes and Determinism</H3><UL>
<LI>nonground(+, ?, -) is semidet
</UL>
<H3>Fail Conditions</H3>
Fails if Term contains less than N variables
<H3>Exceptions</H3>
<DL>
<DT><EM>(4) instantiation fault </EM>
<DD>N is not instantiated.
<DT><EM>(5) type error </EM>
<DD>VarList instantiated but not to a list.
<DT><EM>(6) out of range </EM>
<DD>N is not positive.
</DL>
<H2>Examples</H2>
<PRE>
Success:
    nonground(1, Term, L).       % gives L = [Term]
    nonground(1, f(a,B,c), L).   % gives L = [B]
    nonground(2, [X,Y,Z], L).    % gives L = [Y,X]
    nonground(2, [X,Y,Z], L).    % gives L = [Y,X]
    nonground(1, s(X{a}), L).    % gives L = [X{a}]

Fail:
    nonground(1, atom, L).
    nonground(2, f(a,B,c), L).
    nonground(2, [X,X,X], L).



</PRE>
<H2>See Also</H2>
<A HREF="../../kernel/typetest/nonground-1.html">nonground / 1</A>, <A HREF="../../kernel/typetest/nonground-2.html">nonground / 2</A>, <A HREF="../../kernel/typetest/nonvar-1.html">nonvar / 1</A>, <A HREF="../../kernel/typetest/var-1.html">var / 1</A>
</BODY></HTML>
